<?php
$user = Yii::app()->user;

$menuItems = array(
	array(
		'label' => '用户 - '
			. ($user->isGuest ? '未登陆' : AccessControl::getCurrentUser()->employee->fullName),
		'iconClass' => 'icon-user',
		'items' => array(
			array(
				'label' => '修改密码',
				'url' => array(
					'/user/passwordChange'
				),
				'visible' => !$user->isGuest
			),
			array(
				'label' => '退出 (' . $user->name . ')',
				'url' => array(
					'/site/logout'
				),
				'visible' => !$user->isGuest
			),
		),
	),
	array(
		'label' => '首页',
		'iconClass' => 'icon-house',
		'url' => array(
			'/site/index'
		),
	),
	array(
		'label' => '高级管理',
		'iconClass' => 'icon-computer',
		'items' => array(
			array(
				'label' => '统计报表',
				'url' => array(
					'/site/statistics'
				),
				'visible' => false,
			),
			array(
				'label' => '登陆管理',
				'url' => array(
					'/user/admin'
				),
				'visible' => $user->checkAccess('admin'),
				'items' => array(
					array(
						'label' => '新建登陆',
						'url' => array(
							'/user/create'
						),
						'visible' => $user->checkAccess('admin'),
					),
				),
			),
			array(
				'label' => '权限管理',
				'url' => array(
					'/userAccess/admin'
				),
				'visible' => $user->checkAccess('admin'),
			),
		),
	),
	array(
		'label' => '日常工作',
		'iconClass' => 'icon-award-star-bronze-1',
		'items' => array(
			array(
				'label' => '每日工作',
				'url' => array(
					'/employeeDailyReport/index'
				),
				'visible' => !$user->isGuest
			),
		),
	),
	array(
		'label' => '员工及证书',
		'iconClass' => 'icon-group',
		'items' => array(
			array(
				'label' => '员工管理',
				'url' => array(
					'/employee/index'
				),
				'visible' => $user->checkAccess('employeeView'),
				'items' => array(
					array(
						'label' => '新建员工',
						'url' => array(
							'/employee/create'
						),
						'visible' => $user->checkAccess('employeeManage'),
					),
				),
			),
			array(
				'label' => '员工证书',
				'url' => array(
					'/employeeCertificate/index'
				),
				'visible' => $user->checkAccess('employeeView'),
			),
		),
	),
	array(
		'label' => '统计分析',
		'iconClass' => 'icon-report',
		'items' => array(
			array(
				'label' => '材料价格查询',
				'url' => array(
					'/materialStatistic/viewPrice'
				),
				'iconClass' => 'icon-report-key',
				'visible' => $user->checkAccess('materialPriceCheck'),
			),
			array(
				'label' => '项目材料流水',
				'url' => array(
					'/materialStatistic/viewProject'
				),
				'iconClass' => 'icon-report-key',
				'visible' => $user->checkAccess('projectMaterialAnalyze'),
			),
			array(
				'label' => '项目材料分析',
				'url' => array(
					'/materialStatistic/projectMaterialAnalyze'
				),
				'iconClass' => 'icon-report-key',
				'visible' => $user->checkAccess('projectMaterialAnalyze'),
			),
		),
	),
	array(
		'label' => '公司资质',
		'iconClass' => 'icon-award-star-bronze-3',
		'items' => array(
			array(
				'label' => '资质浏览',
				'url' => array(
					'/companyCertificate/index'
				),
				'visible' => $user->checkAccess('employeeView'),
				'items' => array(
					array(
						'label' => '新建资质',
						'url' => array(
							'/companyCertificate/create'
						),
						'visible' => $user->checkAccess('employeeManage'),
					),
				),
			),
		),
	),
	array(
		'label' => '材料及供货商',
		'iconClass' => 'icon-cog',
		'items' => array(
			array(
				'label' => '材料浏览',
				'url' => array(
					'/material/index'
				),
				'visible' => $user->checkAccess('materialView'),
			),
			array(
				'label' => '材料管理',
				'url' => array(
					'/material/admin'
				),
				'visible' => $user->checkAccess('materialManage'),
			),
			array(
				'label' => '供货商查看',
				'url' => array(
					'/merchant/index'
				),
				'visible' => $user->checkAccess('merchantView'),
			),
			array(
				'label' => '供货商管理',
				'url' => array(
					'/merchant/admin'
				),
				'visible' => $user->checkAccess('merchantManage'),
			),
		),
	),
	array(
		'label' => '材料流程',
		'iconClass' => 'icon-lorry',
		'items' => array(
			array(
				'label' => '申购单查看',
				'url' => array(
					'/materialRequisition/index'
				),
				'visible' => $user->checkAccess('materialRequisitionView'),
			),
			array(
				'label' => '申购单管理',
				'url' => array(
					'/materialRequisition/admin'
				),
				'visible' => $user->checkAccess('materialRequisitionManage'),
			),
			array(
				'label' => '入库单查看',
				'url' => array(
					'/materialWarehouseInbound/index'
				),
				'visible' => $user->checkAccess('materialWarehouseInboundView'),
			),
			array(
				'label' => '入库单管理',
				'url' => array(
					'/materialWarehouseInbound/admin'
				),
				'visible' => $user->checkAccess('materialWarehouseInboundManage'),
			),
			array(
				'label' => '三级账查看',
				'url' => array(
					'/materialReceipt/index'
				),
				'visible' => $user->checkAccess('materialReceiptView'),
			),
			array(
				'label' => '三级账管理',
				'url' => array(
					'/materialReceipt/admin'
				),
				'visible' => $user->checkAccess('materialReceiptManage'),
			),
			array(
				'label' => '我的报销单',
				'url' => array(
					'/materialReceipt/listExpense'
				),
				'visible' => $user->checkAccess('materialExpense'),
			),
			array(
				'label' => '生成报销单',
				'url' => array(
					'/materialReceipt/generateExpense'
				),
				'visible' => $user->checkAccess('materialExpense'),
			),
			array(
				'label' => '报销单外部凭证编号',
				'url' => array(
					'/materialReceipt/attachExpenseExternal'
				),
				'visible' => $user->checkAccess('materialReceiptManage'),
			),
		)
	),
	array(
		'label' => '收付款',
		'iconClass' => 'icon-page-white-text',
		'items' => array(
			array(
				'label' => '收款账查看',
				'url' => array(
					'/accountReceivable/index'
				),
				'visible' => $user->checkAccess('accountView'),
			),
			array(
				'label' => '收款账管理',
				'url' => array(
					'/accountReceivable/admin'
				),
				'visible' => $user->checkAccess('accountManage'),
			),
			array(
				'label' => '付款账查看',
				'url' => array(
					'/accountPayable/index'
				),
				'visible' => $user->checkAccess('accountView'),
			),
			array(
				'label' => '付款账管理',
				'url' => array(
					'/accountPayable/admin'
				),
				'visible' => $user->checkAccess('accountManage'),
			),
		),
	),
	array(
		'label' => '财务凭证',
		'iconClass' => 'icon-package',
		'items' => array(
			array(
				'label' => '凭证账本管理',
				'url' => array(
					'/accountTokenProject/admin'
				),
				'visible' => $user->checkAccess('accountTokenManage')
					&& !AccessControl::isAltMode(),
			),
			array(
				'label' => '凭证科目管理',
				'url' => array(
					'/accountTokenCategory/admin'
				),
				'visible' => $user->checkAccess('accountTokenManage'),
			),
			array(
				'label' => '凭证查看',
				'url' => array(
					'/accountToken/index'
				),
				'visible' => $user->checkAccess('accountTokenManage'),
			),
			array(
				'label' => '凭证管理',
				'url' => array(
					'/accountToken/admin'
				),
				'visible' => $user->checkAccess('accountTokenManage'),
			),
			array(
				'label' => '凭证统计报表',
				'url' => array(
					'/accountToken/stat'
				),
				'visible' => $user->checkAccess('accountTokenStat'),
			),
			array(
				'label' => '设置凭证账本',
				'url' => array(
					'accountTokenProject/setGlobalProject'
				),
				'visible' => $user->checkAccess('accountTokenView'),
			),
			array(
				'label' => '报销单附凭证',
				'url' => array(
					'/materialReceipt/attachExpenseExternal'
				),
				'visible' => $user->checkAccess('accountTokenManage'),
			),
		),
	),
	array(
		'label' => '项目',
		'iconClass' => 'icon-building',
		'items' => array(
			array(
				'label' => '项目查看',
				'url' => array(
					'/project/index'
				),
				'visible' => $user->checkAccess('projectView'),
			),
			array(
				'label' => '项目管理',
				'url' => array(
					'/project/admin'
				),
				'visible' => $user->checkAccess('projectManage'),
			),
		)
	),
	array(
		'label' => '登陆',
		'url' => array(
			'/site/login'
		),
		'visible' => $user->isGuest,
		'linkOptions' => array(
			'class' => 'main-menu-login'
		)
	),
);
//$this->widget('zii.widgets.CMenu', $menu);

//$this->widget('widgets.tree.ZTreeMenuWidget', array(
//		'menuItems' => $menuItems
//	));

$this->widget('widgets.ext.menu.JExtMenu', array(
		'items' => $menuItems
	));
?>
